summaryrefslogtreecommitdiff
path: root/app/[lng]/evcp/(evcp)/evaluation-target-list/page.tsx
blob: 886d061de75054186cd80d99ba9779f233cce0ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import * as React from "react"
import { Metadata } from "next"
import { type SearchParams } from "@/types/table"
import { Shell } from "@/components/shell"
import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton"
import { Badge } from "@/components/ui/badge"

import { getDefaultEvaluationYear, searchParamsEvaluationTargetsCache } from "@/lib/evaluation-target-list/validation"
import { getEvaluationTargets } from "@/lib/evaluation-target-list/service"
import { InformationButton } from "@/components/information/information-button"
import { EvaluationTargetsTable } from "@/lib/evaluation-target-list/table/evaluation-target-table"

export const metadata: Metadata = {
  title: "협력업체 평가 대상 관리",
  description: "협력업체 평가 대상을 확정하고 담당자를 지정합니다.",
}

interface EvaluationTargetsPageProps {
  searchParams: Promise<SearchParams>
}

export default async function EvaluationTargetsPage(props: EvaluationTargetsPageProps) {
  const searchParams = await props.searchParams
  
  // ✅ 간소화된 파싱
  const search = searchParamsEvaluationTargetsCache.parse(searchParams)
  
  // 현재 평가년도
  const currentEvaluationYear = search.evaluationYear || getDefaultEvaluationYear()
  
  // ✅ 단순화된 서비스 호출 (필터 처리는 테이블에서 담당)
  const promises = Promise.all([
    getEvaluationTargets(search)
  ])

  return (
    <Shell className="gap-4">
      {/* Header */}
      <div className="flex items-center justify-between space-y-2">
        <div className="flex items-center gap-2">
          <h2 className="text-2xl font-bold tracking-tight">
            협력업체 평가 대상 관리
          </h2>
          <InformationButton pagePath="evcp/evaluation-target-list" />
          <Badge variant="outline" className="text-sm">
            {currentEvaluationYear}년도
          </Badge>
        </div>
      </div>
                  
      {/* Main Table */}
      <React.Suspense 
        key={`evaluation-targets-${search.page}-${JSON.stringify(search.filters)}-${search.joinOperator}-${search.search || 'no-search'}`}
        fallback={
          <DataTableSkeleton
            columnCount={12}
            searchableColumnCount={2}
            filterableColumnCount={6}
            cellWidths={[
              "3rem",   // checkbox
              "5rem",   // 평가년도
              "4rem",   // 구분
              "8rem",   // 벤더코드
              "12rem",  // 벤더명
              "4rem",   // 내외자
              "6rem",   // 자재구분
              "5rem",   // 상태
              "5rem",   // 의견일치
              "8rem",   // 담당자현황
              "10rem",  // 관리자의견
              "8rem"    // actions
            ]}
            shrinkZero
          />
        }
      >
        <EvaluationTargetsTable
          promises={promises}
          evaluationYear={currentEvaluationYear}
        />
      </React.Suspense>
    </Shell>
  )
}